﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Informaiton_Retrieval.com.ir.Model
{
    class PresentationModel
    {
        public delegate void SomeThing(bool value);
        public SomeThing SomeThingEvent, SomeThingEvent2;

        public delegate void SetProgress(int value);
        public SetProgress SetProgressEvent;

        public delegate void SetMeaasge(string message);
        public SetMeaasge SetMeaasgeEvent;

        MainModel model;

        public PresentationModel() {
            model = new MainModel(this);
        }

        public void OnLoadFile() {            
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter = "txt files (*.warc)|*.warc|All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string filePath = openFileDialog1.FileName;
                model.LoadFile(filePath);
            }
        }

        public void OnSaveOutput() {
            FolderBrowserDialog path = new FolderBrowserDialog();
            path.ShowDialog();
            string pathstr=path.SelectedPath;
            model.SaveFile(pathstr);
        }

        public void SetIsFileInProcess(bool value) {
            if (SomeThingEvent != null)
                SomeThingEvent(!value);
        }

        public void SetIsFileProcessCompleted(bool value)
        {
            if (SomeThingEvent2 != null)
                SomeThingEvent2(value);
        }

        public void OnSetProgress(int value) {
            if (SetProgressEvent != null)
                SetProgressEvent(value);
        }

        public void OnSetMeaasge(string message)
        {
            if (SetMeaasgeEvent != null)
                SetMeaasgeEvent(message);
        }

        public bool CaseFold { get; set; }
        public bool Stopword { get; set; }
        public bool Stemming { get; set; }

    }
}
